﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RTW.OA.Servers;

namespace RTW.OA.Controllers
{
    public class LoginController : Controller
    {
        private LoginServers loginServers;

        public LoginController()
        {
            loginServers = new LoginServers();
        }


        // GET: Login
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Index(string username,string userpassword)
        {
            if (!string.IsNullOrEmpty(username))
            {
                var userinfo = loginServers.Login(username, userpassword);
                if (userinfo!=null)
                {
                    Session["UserInfo"] = userinfo;
                    return RedirectToAction("Index", "Home");
                }
                else {
                    ViewBag.msg = "用户名或密码不正确，请重新填写！";
                }
            }
            else
            {
                ViewBag.msg = "用户名不能为空！";
            }
            return View();
        }
    }
}